{% load i18n %}
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/datatable/assets/skins/sam/datatable.css" />
<script type="text/javascript">
    function deleteSessionToken(user_email, target_service) {
        var sUrl = "/rpc?action=DeleteSessionToken&arg0=\"" + user_email + "\"&arg1=\"" + target_service +
                   "\"&time=" + new Date().getTime();
        var deleteSessionTokenSuccess = function(o) {
            if (o.responseText !== undefined) {
                var src_obj = document.getElementById(o.argument.user_email + "_" + o.argument.target_service);
                document.getElementById("tokentable").deleteRow(src_obj.parentNode.parentNode.rowIndex);
                alert("Delete session token successfully.");
            }
        }
        var callback =
        {
            success:deleteSessionTokenSuccess,
            failure:handleFailure,
            argument:{user_email:user_email,target_service:target_service}
        };
        YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
    }
</script>
<fieldset id="admin_authsub">
    <legend>{% trans "Session Token Management" %}</legend>
    <div class="fieldsetdiv">
        {% trans "Sesseion Token List" %}:
        <table id="tokentable">
            <tr>
                <th>{% trans "User Email" %}</th>
                <th>{% trans "Target Service" %}</th>
                <th>{% trans "Session Token" %}</th>
                <th> &nbsp;</th>
            </tr>
            {% for token in session_tokens %}
            <tr>
                <td>{{token.user_email}}</td>
                <td>{{token.target_service}}</td>
                <td>{{token.session_token}}</td>
                <td>
                    <a href="javascript:deleteSessionToken('{{token.user_email}}','{{token.target_service}}')"
                       id="{{token.user_email}}_{{token.target_service}}">Delete</a>
                </td>
            </tr>
            {% endfor%}
        </table>
    </div>
</fieldset>

